#pragma once

#include "SDCardClass.hpp"
#include <MCF/Code/AbstractThreadClass.hpp>

class SDCardClass::_SDCardThreadClass : public MCF::AbstractThreadClass {
private:
	static void CALLBACK _OnIOComplete(DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped);
private:
	const SDCardClass *const _m_lpSDCard;

	bool _m_bToRead;
	std::size_t _m_uSectorID;
	void *_m_lpBuffer;

	volatile DWORD _m_dwBytesTransferred;
public:
	_SDCardThreadClass(const SDCardClass *lpFile);
	~_SDCardThreadClass();
protected:
	virtual int _ThreadProc();
public:
	void BeginReading(std::size_t uSectorID, BYTE *lpbyBuffer);
	void BeginWriting(std::size_t uSectorID, const BYTE *lpbyBuffer);
	DWORD QueryBytesTransferred() const;
};
